<template>
  <div>
    <!--条件筛选-->
    <TopFilter ref="topFilter" :list="topFilterList" :cols="3" labelWidth="110" @filterChange="changeHandle"
               @onCollapse="collapseHandle"></TopFilter>
    <!-- table -->
    <FilterTable
      ref="table"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :isSelectColumn="false"
      :onColumnsChange="columns => this.columns = columns">
    </FilterTable>

  </div>
</template>

<script>
  import {getuserworkhour} from '@/api/reportManage/salesAfter';
  import { dictionary } from '@/utils/dictMixin';
    export default {
      name: "technicianWorkHours",
      mixins: [dictionary],
      data() {
        return{
          topFilterList: this.createTopFilterList(),
          columns: this.createTableColumns(),
          fetchApi: getuserworkhour,
          fetchParams: { xhrAbort: true },
          visibleDrawer: false,
          handleType: '',
          searchData: {},
          title: '配件信息',
          infoTitle: '明细',
          dialogTitle: '',
          visibleDetail: false,
          initData: {},
          infoData: {}
        };
      },
      methods: {
        createTopFilterList() {
          return[
            {
						type: 'DATE',
						label: '日期',
						fieldName: 'estimatePurchaseDate',
						valueFormat: 'yyyy-MM',
						dateType:'month',
						style: { width: '100%' },
						initialValue: '',
						placeholder:'',
					},
            {
              type: 'SELECT',
              label: '委托单状态',
              fieldName: 'ro_status',
              placeholder: '请选择',
              itemList: this.createDictList('8049')
            },
          ]
        },
        createTableColumns () {
          return [
            {
              title: '操作',
              dataIndex: 'column-action',
              width: 70,
              fixed: 'left',
              render: props => {
                return (
                  <div>
                  <el-button size="mini" type="text" onClick={() => this.getDetail(props.row.technician, this.fetchParams)}>
                  明细
                  </el-button>
                </div>
                );
              }
            },
            {
              title: '序',
              dataIndex: 'index',
              width: 70,
              sorter: true,
              render: props => {
                return <span>{props.row.index + 1}</span>;
              }
            },
            {
              title: '维修技师',
              dataIndex: 'technicianName',
              sorter: true,
              filter: true,
              filterType: 'input'
            },
            {
              title: '派工次数',
              dataIndex: 'count_labour',
              sorter: true,
            },
            {
              title: '工时数',
              dataIndex: 'sum_hour',
              sorter: true,
            },
            // {
            //   title: '班组名称',
            //   dataIndex: '',
            //   sorter: true,
            // }
          ]
        },
        changeHandle(val) {
          val.endTime && (val.endTime = val.endTime.split(' ')[0] + ' 23:59:59');
          this.fetchParams = Object.assign({}, this.fetchParams, val, {xhrAbort: false});
        },
        collapseHandle() {
          this.$nextTick(() => {
            this.BaseTable.EXECUTE_RESET_HEIGHT();
          });
        },
        getDetail(name,value) {
          this.searchData =  {
            name: name,
            param: value
          }; //行id
          this.visibleDetail = true;
        },
        closeInfoHandler(type) {
          this.infoDrawer = false
          if (type === 'refresh') {
            // 重新加载
            this.fetchParams = Object.assign({}, this.fetchParams);
          }
        },
        selectedFun(val){

        },
      }
    }
</script>

<style scoped>

</style>
